package com.sk.sourcecircle.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.sk.sourcecircle.R;
import com.sk.sourcecircle.callback.MyCallBack;

/**
 * Created by sk on 2018/1/11.
 */

public class ViewPagerAdapter extends StaticPagerAdapter {


    private int[] ids;
    private Context context;
    private MyCallBack myCallBack;

    public ViewPagerAdapter(int[] strings, Context context, MyCallBack myCallBack) {
        this.ids = strings;
        this.context = context;
        this.myCallBack = myCallBack;
    }

    @Override
    public View getView(ViewGroup container, final int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_view_pager_img, container, false);
        ImageView imageView = view.findViewById(R.id.img);
        Glide.with(context).load(ids[position]).into(imageView);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (myCallBack != null) {
                    myCallBack.sure();
                }
            }
        });


        return view;
    }

    @Override
    public int getCount() {
        return ids.length;
    }

}
